<#include "./template.ftl">

<#macro head>
<title>全球移动营销第一平台-Morketing</title>
<link rel="stylesheet" href="${base}/client/css/home_style.css">
<link rel="stylesheet" href="${base}/client/css/list.css">
<link rel="stylesheet" href="${base}/client/css/productList.css">
<link rel="stylesheet" href="${base}/client/css/wenda.css">
<style type="text/css">
    #owl-point .img.first {
        background: url(${base}/system/getImg?imgId=${home_banner_img_1}) no-repeat 50% 50%;
        background-size: cover
    }

    #owl-point .img.second {
        background: url(${base}/system/getImg?imgId=${home_banner_img_2}) no-repeat 50% 50%;
        background-size: cover
    }

    #owl-point .img.three {
        background: url(${base}/system/getImg?imgId=${home_banner_img_3}) no-repeat 50% 50%;
        background-size: cover
    }

    #owl-point .img.four {
        background: url(${base}/system/getImg?imgId=${home_banner_img_4}) no-repeat 50% 50%;
        background-size: cover
    }
</style>
</#macro>
<#macro content>
<div id="contents">
    <div id="owl-point" class="owl-carousel">
        <a href="${home_banner_url_1}">
            <div class="img first">
                <div class="overf"></div>
                <div class="wrap text">
                    <div class="title">
                        <div class="h">
                            <h2>${home_banner_title_1}</h2>
                        </div>
                    </div>
                </div>
            </div>
        </a>

        <a href="${home_banner_url_2}">
            <div class="img second">
                <div class="overf"></div>
                <div class="wrap text">
                    <div class="title">
                        <div class="h">
                            <h2>${home_banner_title_2}</h2>
                        </div>
                    </div>
                </div>
            </div>
        </a>

        <a href="${home_banner_url_3}">
            <div class="img three">
                <div class="overf"></div>
                <div class="wrap text">
                    <div class="title">
                        <div class="h">
                            <h2>${home_banner_title_3}</h2>
                        </div>
                    </div>
                </div>
            </div>
        </a>

        <a href="${home_banner_url_4}">
            <div class="img four">
                <div class="overf"></div>
                <div class="wrap text">
                    <div class="title">
                        <div class="h">
                            <h2>${home_banner_title_4}</h2>
                        </div>
                    </div>
                </div>
            </div>
        </a>
    </div>
    <div class="main wrap clearfix">
        <div class="main-left f-l clearfix">
            <div class="index-main-bar">
                <div class="pc"></div>
            </div>
            <div class="index-tab">
                <ul class="news-tabs">
                    <li class="active js-cat"><a data-cat="0">全部</a></li>
                    <li class="js-cat"><a data-cat="172">资讯</a></li>
                    <li class="js-cat"><a data-cat="171">对话</a></li>
                    <li class="js-cat"><a data-cat="169">观点</a></li>
                    <li class="js-cat"><a data-cat="162">人事</a></li>
                    <li class="js-cat"><a data-cat="164">案例</a></li>
                </ul>
                <div class="news-item show">
                    <#if vos??>
                        <#list vos as v>
                            <div class="li-item">
                                <div class="rel
                                    <#if v.postTerm ==164>rel1</#if>
                                    <#if v.postTerm ==162>rel3</#if>
                                    <#if v.postTerm ==169>rel2</#if>
                                    <#if v.postTerm ==171>rel4</#if>
                                    <#if v.postTerm ==172>rel0</#if>
                                    ">
                                    <#if v.postTerm ==164>案例</#if>
                                    <#if v.postTerm ==162>人事</#if>
                                    <#if v.postTerm ==169>观点</#if>
                                    <#if v.postTerm ==171>对话</#if>
                                    <#if v.postTerm ==172>资讯</#if>
                                </div>
                                <div class="f-l l">
                                    <a href="${base}/posts/${v.id}" style="display: inline-block;width: inherit;height: inherit">
                                        <div style="height:100%;width:160%;margin-left: -30%;text-align: center">
                                            <img style="height:100%;width:auto" src="${base}/system/getImg?imgId=${v.postImg}&h=168&w=224" >
                                        </div>
                                    </a>
                                </div>
                                <div class="cell">
                                    <h2><a href="${base}/posts/${v.id}">${v.postTitle}</a></h2>
                                    <p>${v.postContent}</p>
                                    <div class="tips">
                                        <div class="from"><span class="time">来自:<a href="${base}/profile?userId=${v.postAuthor!''}">${v.postAuthorStr}</a> | ${v.createTimeStr}</span> <span class="view">${v.view}</span></div>
                                        <div class="share">share on： <span class="social-share share-component" data-initialized="true"><a href="http://service.weibo.com/share/share.php?url=file%3A%2F%2F%2FUsers%2Fzhanshanqin%2Fproject%2Fdashboard%2Findex.html&amp;title=%E9%A6%96%E9%A1%B5&amp;pic=file%3A%2F%2F%2FUsers%2Fzhanshanqin%2Fproject%2Fdashboard%2F1cbcd0feb28bd14a067f087f96a82a7c.jpg" class="social-share-icon icon-weibo"></a> <a href="javascript:;" class="social-share-icon icon-wechat"><div class="wechat-qrcode"><h4>微信扫一扫：分享</h4><div class="qrcode"><img src=""></div><div class="help"> </div></div></a></span></div>
                                    </div>
                                </div>
                            </div>
                        </#list>
                        <div class="index-page">
                            <div class="mod-page">
                            ${pages!''}
                            </div>
                        </div>
                    </#if>
                </div>
            </div>
        </div>

        <div class="main-right f-r clearfix" data-index="true">
            <#include "widget/ad.ftl"/>
            <#include "widget/daka.ftl"/>
            <#include "widget/hot_product.ftl"/>
            <#include "widget/hotHIre.ftl"/>
            <#include "widget/lastedQuestionWithoutAsk.ftl"/>
            <#include "widget/weixin.ftl"/>
        </div>
    </div>
    <#include "widget/friend_ship.ftl"/>
</div>
</#macro>
<#macro js>
<script src="${base}/client/js/index.js"></script>
<script src="${base}/client/js/list.js"></script>
<script type="text/javascript">
    $(function(){
        var contentsTpl = '' +
                '{{each data.list as v i}}' +
                '<div class="li-item">' +
                '{{if v.postTerm==172 }}'+
                '       <div class="rel rel0">{{v.postTermsStr}}</div>'+

                '{{else if v.postTerm== 171}}'+
                '       <div class="rel rel4">{{v.postTermsStr}}</div>'+

                '{{else if v.postTerm== 169}}'+
                '       <div class="rel rel2">{{v.postTermsStr}}</div>'+

                '{{else if v.postTerm== 162}}'+
                '       <div class="rel rel3">{{v.postTermsStr}}</div>'+

                '{{else}}'+
                '       <div class="rel rel1">{{v.postTermsStr}}</div>'+
                '{{/if}}'+

                '<div class="f-l l"><img src="${base}/system/getImg?imgId={{v.postImg}}&w=168" alt="" style="height:100%;width:auto"></div>' +
                '<div class="cell">' +
                '   <h2><a href="${base}/posts/{{v.id}}">{{v.postTitle}}</a></h2>' +
                '   <p>{{#v.postContent}}</p>' +
                '   <div class="tips">' +
                '       <div class="from">' +
                '           <span class="time">来自:<a href="${base}/profile?userId={{v.postAuthor}}">{{v.postAuthorStr}}</a> | {{v.createTimeStr}}</span>' +
                '           <span class="view">{{v.view}}</span>' +
                '       </div>' +
                '       <div class="share">分享至：' +
                '           <span class="social-share" data-initialized="true">' +
                '               <a href="${base}/posts/{{v.id}}" class="social-share-icon icon-weibo"></a>' +
                '               <a href="${base}/posts/{{v.id}}" class="social-share-icon icon-wechat"></a>' +
                '           </span>' +
                '       </div>' +
                '   </div>' +
                '</div>' +
                '</div>' +
                '{{/each}}';

        //首页分类点击事件
        var isload=false;
        $('.js-cat a').on('click',function(e){
            if(isload) return false;
            e && e.preventDefault();
            var cat=$(this).data('cat');
            var parent=$(this).parent();

            parent.addClass('active').siblings().removeClass('active');
            isload=true;
            var ajax_data = {
                cat: cat,
                posts_per_page: 10
            };
            $.ajax({
                url: '${base}/home/postsList',
                type: 'GET',
                dataType: 'json',
                data:ajax_data,
                success:function(res){
                    isload=false;
                    if(res.status==1){
                        var html = template.render(contentsTpl)(res);
                        $('.news-item').html(html);
                        $('.news-item').append('<div class="index-page"></div>');
                        var Page = new Pagination(
                                $('.index-page'),
                                {
                                    totalNums: res.data.total || 0,//数据总条数，必填
                                    pageSize: 10,//每页显示条数
                                    currentPage: 1,//当前页码
                                    pageClickCallBack:pageClickEvent
                                }
                        )
                        console.log(Page);
                    }else{
                        console.log('出错了')
                    }
                },
                error:function(){
                    isload=false;
                }
            })

        });


        function pageClickEvent (page){
            var cat=$('.news-tabs').find('.active a').data('cat');
            var ajax_data = {
                cat: cat,
                posts_per_page: 10,
                page:page
            };
            $.ajax({
                url: '${base}/home/postsList',
                type: 'GET',
                dataType: 'json',
                data:ajax_data,
                success:function(res){
                    if(res.status == 1){
                        var html = template.render(contentsTpl)(res);
                        $('.news-item').html(html);
                        $('.news-item').append('<div class="index-page"></div>');
                        var Page = new Pagination(
                                $('.index-page'),
                                {
                                    totalNums: res.data.total || 0,//数据总条数，必填
                                    pageSize: 10,//每页显示条数
                                    currentPage: page,//当前页码
                                    pageClickCallBack:pageClickEvent
                                }
                        )
                    }else{
                        console.log('出错了')
                    }
                }
            })
        }
    });
</script>

</#macro>